package cn.tedu.rabbitmqspringboot.m1;

import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import javax.annotation.PostConstruct;

@SpringBootApplication
public class Main {
    @Autowired
    private Producer p;

    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }

    /*
    - springboot项目完整启动完成
    - 当前对象中需要注入的对象注入完成
     */
    @PostConstruct
    public void test() {
        p.send();
    }

    /*
    封装队列参数的对象

    RabbitAutoConfiguration 自动配置类，会自动发现Queue实例，
    在服务器上定义该队列
     */
    @Bean
    public Queue helloworldQueue() {
        //return new Queue("helloworld"); // true, false, false
        return new Queue("helloworld", false);
    }
}
